package im.vinci.server.discovery.controller;

import im.vinci.server.discovery.domain.Music;
import im.vinci.server.discovery.domain.wrappers.DiscoveryResponse;
import im.vinci.server.discovery.service.DiscoveryService;
import im.vinci.server.security.ApiSecurityLabel;
import im.vinci.server.utils.apiresp.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by mingjie on 16/10/26.
 */
@RestController
@RequestMapping(value = "/vinci/discovery", produces = "application/json;charset=UTF-8")
public class DiscoveryController {

    @Autowired
    private DiscoveryService discoveryService;

    //主页显示
    @RequestMapping(value = "/homepage", method = RequestMethod.GET)
    @ApiSecurityLabel(isCheckLogin = true)
    public ResultObject<DiscoveryResponse> homePage() {
        return new ResultObject<>(discoveryService.showHomePage());
    }

    //获取歌曲列表：歌单到歌曲
    @RequestMapping(value = "/musiclist", method = RequestMethod.GET)
    @ApiSecurityLabel(isCheckLogin = true)
    public ResultObject<List<Music>> songList(@RequestParam("id") long id) {

        return new ResultObject<>(discoveryService.getMusicList(id));
    }

}
